import axios from 'axios'
import Vue from 'vue'

const service = axios.create({
  baseURL: '/',
  timeout: 20 * 1000,
  headers: {
    'Cache-Control': 'no-cache'
  }
})
service.interceptors.request.use((config) => {
  if (localStorage.getItem('token')) {
    if (config.url !== '/login/password') {
      config.headers['authorization'] ='Bearer '+ localStorage.getItem('token')
    }
  }
  return config;
})
service.interceptors.response.use((response) => {
  const res = response
  console.log(res)

  return res.data

})
export default service
